using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace TripleMatch
{
    public class DataManager : MonoBehaviour
    {
        private static DataManager s;
        public static DataManager S
        {
            get {
                return s;
            }
        }

        private void Awake()
        {
            s = this;
        }

        private int m_level = -1;
        public int level
        {
            get {
                if (m_level == -1) m_level = PlayerPrefs.GetInt(GameDefine.SaveKey_CurrentLevel, 0);
                return m_level;
            }
            set {
                m_level = value;
                PlayerPrefs.SetInt(GameDefine.SaveKey_CurrentLevel, m_level);
            }
        }

        private int m_difficulty = -1;
        public int difficulty
        {
            get
            {
                if (m_difficulty == -1) m_difficulty = PlayerPrefs.GetInt(GameDefine.SaveKey_CurrentDifficulty, 0);
                return m_difficulty;
            }
            set
            {
                m_difficulty = value ;
                PlayerPrefs.SetInt(GameDefine.SaveKey_CurrentDifficulty, m_difficulty);
            }
        }

        private int m_audioIsOpen = -1;
        public bool audioIsOpen
        {
            get
            {
                if (m_audioIsOpen == -1) m_audioIsOpen = PlayerPrefs.GetInt(GameDefine.SaveKey_AudioState, 1);
                return m_audioIsOpen == 1;
            }
            set
            {
                m_audioIsOpen = value ? 1 : 0;
                PlayerPrefs.SetInt(GameDefine.SaveKey_AudioState, m_audioIsOpen);
            }
        }
    }
}
